<?php

namespace plugin\webman\gateway;

use app\common\library\QueueRedis;
use GatewayWorker\Lib\Gateway;

class Events
{
    public static function onWorkerStart($worker)
    {

    }

    public static function onConnect($client_id)
    {
        Gateway::sendToClient($client_id, json_encode(array(
            'type'      => 'init',
            'client_id' => $client_id
        )));
        var_dump($client_id . "------connect  plugin/webman/gateway/Events.php:21" . PHP_EOL);
        QueueRedis::delay('CloseClient', config('client.bind_time'), ['client_id' => $client_id]);
    }

    public static function onWebSocketConnect($client_id, $data)
    {

    }

    public static function onMessage($client_id, $message)
    {
        Gateway::sendToClient($client_id, "receive message $message");
    }

    public static function onClose($client_id)
    {

    }

}
